using DG.Tweening;
using UnityEngine;
using Voodoo.Pattern;

public class MissileLauncher : MonoBehaviour
{
	public Transform Barrel;

	public Transform LaunchPoint;

	public Missile MissilePrefab;

	public Transform CameraTarget;

	private void Start()
	{
	}

	private void Update()
	{
	}

	private void OnEnable()
	{
		LaunchMissiles();
	}

	public void LaunchMissiles()
	{
		Barrel.right = Vector3.right;
		Barrel.Rotate(new Vector3(0f, 0f, 45f), Space.Self);
		SingletonMB<GameManager>.Instance.Cam.custom = CameraTarget;
		SingletonMB<GameManager>.Instance.Cam.customFOV = 80f;
		Sequence s = DOTween.Sequence();
		s.Append(Barrel.DORotate(new Vector3(0f, 0f, 45f), 1f).OnComplete(delegate
		{
			LaunchMissile();
		}));
		s.Append(Barrel.DORotate(new Vector3(0f, 0f, 30f), 1f).OnComplete(delegate
		{
			LaunchMissile();
		}));
		s.Append(Barrel.DORotate(new Vector3(0f, 0f, 15f), 1f).OnComplete(delegate
		{
			LaunchMissile();
		}));
		s.Append(Barrel.DORotate(new Vector3(0f, 0f, 0f), 1f).OnComplete(delegate
		{
			LaunchMissile();
		}));
		s.Append(Barrel.DORotate(new Vector3(0f, 0f, 0f), 1f)).OnComplete(delegate
		{
			SingletonMB<GameManager>.Instance.Cam.custom = null;
			base.gameObject.SetActive(value: false);
		});
	}

	private void LaunchMissile()
	{
		SingletonMB<GameManager>.Instance.GameplayHaptic.PlayHaptic(HapticType.Small);
		Missile missile = Object.Instantiate(MissilePrefab);
		missile.transform.right = LaunchPoint.right;
		missile.gameObject.SetActive(value: true);
		missile.transform.position = LaunchPoint.position;
	}
}
